package test;

import intel.Flyweight;
import intel.factory.FlyweightFactory;
import intel.flyweight.UnsharedConcreteFlyweight;

/**
 * @ClassName FlyweightPattern
 * @Description: TODO
 * @Author lxc
 * @Date 2020/3/21 14:11
 * @Version V1.0
 **/
public class FlyweightPattern {

    public static void main(String[] args) {
        FlyweightFactory factory=new FlyweightFactory();
        Flyweight f01=factory.getFlyweight("a");
        Flyweight f02=factory.getFlyweight("a");
        Flyweight f03=factory.getFlyweight("a");
        Flyweight f11=factory.getFlyweight("b");
        Flyweight f12=factory.getFlyweight("b");
        f01.operation(new UnsharedConcreteFlyweight("第1次调用a。"));
        f02.operation(new UnsharedConcreteFlyweight("第2次调用a。"));
        f03.operation(new UnsharedConcreteFlyweight("第3次调用a。"));
        f11.operation(new UnsharedConcreteFlyweight("第1次调用b。"));
        f12.operation(new UnsharedConcreteFlyweight("第2次调用b。"));
    }
}
